<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<!DOCTYPE HTML>
<html>
<head>
<%@include file="/WEB-INF/pages/header.jsp" %>
<title>修改自己的密码</title>
</head>
<body>
<div class="pd-20">
<script type="text/javascript">
        $(function(){
        	
            $("form").validate({
                'rules':{
                	
                },
                messages:{
                	
                },
                submitHandler:function(form){
                    // ajaxSubmitForm(form,true)
//弹出来一个确认框，如果点了确认，就返回true,否则就返回false
                    var bool = window.confirm("确定要进行此操作吗？");

                    //如果用户点了确认按钮
                    if(bool) {
                        //form.action就是要发送的链接地址
                        //$(form).serialize()，把所有的表单的值封装成一个对象 {"password":"123,"newPassword":123456,"renewpassword":"123456"}
                        //function，成功之后要做什么？请求成功之后，后端servlet返回的值就放在ajaxResult
                        //'json'，返回值为json对象
                        $.post(form.action, $(form).serialize(), function (ajaxResult) {
                            alert(ajaxResult.msg);

                            if (ajaxResult.code == 200) {
                                //刷新父页面
                                //http://localhost:8080/bqg/
                                parent.location.reload();
                            } else {
                                location.reload();
                                //刷新本页面
                            }
                        }, 'json');
                        event.preventDefault();
                    }





                    // ajaxSubmitForm(form,true)
                }
            });
        });
       
    </script>
    <form action="<%=ctxPath %>/author/updatePassword" class="form form-horizontal">
    
        <div class="row cl">
            <label class="form-label col-2">旧密码</label>
            <div class="formControls col-5">
                <input type="password" class="input-text"  name="password" />
            </div>
            <div class="col-5"></div>
        </div>

        <div class="row cl">
            <label class="form-label col-2">新密码</label>
            <div class="formControls col-5">
                <input type="password" class="input-text"  name="newpassword" />
            </div>
            <div class="col-5"></div>
        </div>
        
        <div class="row cl">
            <label class="form-label col-2">重复新密码</label>
            <div class="formControls col-5">
                <input type="password" class="input-text"  name="renewpassword" />
            </div>
            <div class="col-5"></div>
        </div>

        <div class="row cl">
            <div class="col-9 col-offset-2">
                <input class="btn btn-primary radius" type="submit" value="修改" />
                <input class="btn btn-default radius" type="button" value="关闭" onclick="parent.location.reload()" style="margin-left: 30px;" />
            </div>
        </div>
    </form>
</div>
</body>
</html>